//
//  YTCamerSetViewController.m
//  YUNT
//
//  Created by 小萌 on 2017/11/12.
//  Copyright © 2017年 梁炜东. All rights reserved.
//

#import "YTCamerSetViewController.h"
#import "YTVideoSetViewController.h"
#import "YTCamerSetCell.h"
#import "YTSetModel.h"
#import "YTWhiteBalanceViewController.h"
#import "YTBeautyViewController.h"
#import "YTFlightViewController.h"
#import "YTGridViewController.h"

static NSString *identifier = @"YTCamerSetCell";
@interface YTCamerSetViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSArray *array;
@end

@implementation YTCamerSetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"相机";
    self.view.backgroundColor = [UIColor colorWithHexString:@"#2e2e2e"];
    [self.tableView registerNib:[UINib nibWithNibName:@"YTCamerSetCell" bundle:nil] forCellReuseIdentifier:identifier];
    // Do any additional setup after loading the view from its nib.
}
- (NSArray *)array
{
    if (!_array) {
        YTSetModel *model1 = [[YTSetModel alloc] init];
        model1.name = @"视频分辨率";
        model1.logo = @"";
        YTSetModel *model2 = [[YTSetModel alloc] init];
        model2.name = @"美颜效果";
        model2.logo = @"";
        YTSetModel *model3 = [[YTSetModel alloc] init];
        model3.name = @"白平衡";
//        model3.logo = @"35";
        YTSetModel *model4 = [[YTSetModel alloc] init];
        model4.name = @"闪光灯";
        YTSetModel *model5 = [[YTSetModel alloc] init];
        model5.name = @"网格";
        model5.logo = @"33";
        _array = @[model1,model2,model3,model4,model5];
    }
    return _array ;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YTCamerSetCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
    cell.row = indexPath.row;
    [cell cofigWithModel:self.array[indexPath.row]];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 62;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    IMP_BLOCK_SELF(YTCamerSetViewController);
    if (indexPath.row == 0) {
        YTVideoSetViewController *videoVC = [[YTVideoSetViewController alloc] init];
        [self.navigationController pushViewController:videoVC animated:YES];
    }else if (indexPath.row == 1){
        YTBeautyViewController *beautyVC = [[YTBeautyViewController alloc] init];
        [self.navigationController pushViewController:beautyVC animated:YES];
    }else if (indexPath.row == 2){
        YTWhiteBalanceViewController *whiteBalance = [[YTWhiteBalanceViewController alloc] init];
        whiteBalance.handler = ^(id sender) {
            [block_self.tableView reloadData];
        };
        [self.navigationController pushViewController:whiteBalance animated:YES];
    }else if (indexPath.row == 3){
        YTFlightViewController *flightVC = [[YTFlightViewController alloc] init];
        flightVC.handler = ^(id sender) {
            [block_self.tableView reloadData];
        };
        [self.navigationController pushViewController:flightVC animated:YES];
    }else{
        YTGridViewController *gridVC =[[YTGridViewController alloc] init];
        [self.navigationController pushViewController:gridVC animated:YES];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
